package Week7;

import Week7.Read;

import java.io.*;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Day38 {
}
//牛客:天使果冻
class Main2{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] arr = new int[n + 1];
        for(int i = 1; i <= n; i++){
            arr[i] = in.nextInt();
        }
        // 更新最⼤值以及次⼤值shuzu
        int[] f = new int[n + 1];
        int[] g = new int[n + 1];
        f[1] = arr[1];
        for(int i = 2; i <= n; i++){
            int x = arr[i];
            f[i] = Math.max(f[i - 1], x);
            if(x >= f[i - 1]) g[i] = f[i - 1];
            else if(x >= g[i - 1]) g[i] = x;
            else g[i] = g[i - 1];
        }
        int q = in.nextInt();
        while(q-- != 0){
            int x = in.nextInt();
            System.out.println(g[x]);
        }
    }
}

//牛客:dd爱旋转
class Main3 {
    public static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    public static Read in = new Read();
    public static int n;
    public static int[][] arr;
    public static void setRow()
    {
        for(int i = 0; i < n / 2; i++)
        {
            for(int j = 0; j < n; j++)
            {
// arr[i][j] 与 arr[n - 1 - i][j]
                int tmp = arr[i][j];
                arr[i][j] = arr[n - 1 - i][j];
                arr[n - 1 - i][j] = tmp;
            }
        }
    }
    public static void setCol()
    {
        for(int j = 0; j < n / 2; j++) {
            for(int i = 0; i < n; i++) {
                // arr[i][j] 与 arr[i][n - 1 - j]
                int tmp = arr[i][j];
                arr[i][j] = arr[i][n - 1 - j];
                arr[i][n - 1 - j] = tmp;
            }
        }
    }
    public static void main(String[] args) throws IOException
    {
        n = in.nextInt();
        arr = new int[n][n];
        for(int i = 0; i < n; i++)
        {
            for(int j = 0; j < n; j++)
            {
                arr[i][j] = in.nextInt();
            }
        }
        int q = in.nextInt();
        int row = 0, col = 0;
        while(q-- != 0)
        {
            int x = in.nextInt();
            if(x == 1)
            {
                row++; col++;
            }
            else
            {
                row++;
            }
        }
        // 优化
        row %= 2; col %= 2;
        if(row != 0) setRow();
        if(col != 0) setCol();
        for(int i = 0; i < n; i++)
        {
            for(int j = 0; j < n; j++)
            {
                out.print(arr[i][j] + " ");}
            out.println("");
        }
        out.close();
    }
}
class Read // ⾃定义快速读⼊
{
    StringTokenizer st = new StringTokenizer("");
    BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
    String next() throws IOException
    {
        while(!st.hasMoreTokens())
        {
            st = new StringTokenizer(bf.readLine());
        }
        return st.nextToken();
    }
    String nextLine() throws IOException
    {
        return bf.readLine();
    }
    int nextInt() throws IOException
    {
        return Integer.parseInt(next());
    }
    long nextLong() throws IOException
    {
        return Long.parseLong(next());
    }
    double nextDouble() throws IOException
    {
        return Double.parseDouble(next());
    }
}

//牛客:DP40 小红取数
class Main4 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), k = in.nextInt();
        long[] a = new long[n + 1];
        for (int i = 1; i <= n; i++) {
            a[i] = in.nextLong();
        }
        long[][] dp = new long[n + 1][k];
        for (int i = 0 ; i <= n; i++) {
            for (int j = 0; j < k; j++) {
                dp[i][j] = (long) -1e16;
            }
        }
        dp[0][0] = 0;
        for (int i = 1; i <= n; i++)

        {
            for (int j = 0; j < k; j++) {
                dp[i][j] = Math.max(dp[i - 1][j], dp[i - 1][(int)((j - a[i] % (long)k + (long)k) % (long)k)] + a[i]);
            }
        }
        if (dp[n][0] > 0) System.out.println(dp[n][0]);
        else System.out.println(-1);
    }
}